package com.furnitur.modules.portal.controller;

import com.furnitur.common.api.Result;
import com.furnitur.modules.portal.service.PortalFavoriteService;
import com.furnitur.modules.portal.vo.favorite.FavoriteVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/portal/favorite")
public class PortalFavoriteController {

    @Autowired
    private PortalFavoriteService favoriteService;

    @PostMapping("/{furnitureId}")
    public Result<Void> addFavorite(@PathVariable Long furnitureId) {
        favoriteService.addFavorite(furnitureId);
        return Result.success();
    }

    @DeleteMapping("/{furnitureId}")
    public Result<Void> removeFavorite(@PathVariable Long furnitureId) {
        favoriteService.removeFavorite(furnitureId);
        return Result.success();
    }

    @GetMapping("/list")
    public Result<List<FavoriteVO>> getFavoriteList() {
        return Result.success(favoriteService.getFavoriteList());
    }

    @GetMapping("/check/{furnitureId}")
    public Result<Boolean> checkFavorite(@PathVariable Long furnitureId) {
        return Result.success(favoriteService.isFavorite(furnitureId));
    }
} 